<div class="fsh-rightPanel">
    <label> <input type="password" style="display: none"></label>
    <div class="layui-anim layui-anim-upbit">
        <div class="layui-form-item wx-search" id="list_form">
            <div class="layui-inline">
                <input type="text" name="nickname" placeholder="请输入作业标题" autocomplete="off" class="layui-input">
            </div>
            <button class="layui-btn btn-primary" id="search">搜索</button>
        </div>
        <table id="list_table" class="layui-hide" lay-filter="mainList"></table>
    </div>
</div>
<script>
    layui.use(['layer', 'table'], function () {
        var layer = layui.layer;
        var table = layui.table;

        var tableObj = table.render({
            elem: '#list_table',
            url: context + '/api/task/getListCreateAjob?parent_id=0',
            request: {
                limitName: 'pageSize' //每页数据量的参数名，默认：limit
            },
            align: 'center'
            , cols: [[ //表头
                {field: 'numbers', title: '序号', align: 'left',width:120},
                {field: 'title', title: '标题', align: 'center'},
                {field: 'resource_url', title: '附件', align: 'center'},
                {field: 'createDate', title: '创建日期', align: 'center'},
                {
                    field: 'lock', title: '操作', width: 200, unresize: true, align: 'center',
                    templet: function (d) {
                        return '<a href="javascript:;" class="font-primary" lay-event="dispatch">分配作业</a>'
                    }
                }
            ]]
            , page: true

        });

        // 检索
        $("#search").click(function () {
            reloadTable(tableObj);
        });

        //表格内部操作按钮监听
        table.on('tool(mainList)', function (obj) { //注：tool是工具条事件名，mainList是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            console.log(data)
            // 分配角色
            if (layEvent === 'dispatch') {
                showDialog({
                    title: '分配作业'
                    , template: 'dispatch'
                    , htmlData: data
                    , yes: function (index, layero) {
                        layer.close(index);
                    }

                })
            }
        });

    });
</script>
